package com.xii.staservice.controller;


import com.xii.commonutils.R;
import com.xii.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author xhjava
 * @since 2022-03-24
 */
@RestController
@RequestMapping("/staservice/sta")
//@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;
    /**
     * @description: 获取每日的数据统计 添加到statictics表
     *
     * @return {@link null}
     * @author  wangxihao
     * @email wangxh0108@163.com
    **/
    @PostMapping("{day}")
    public R createStatisticsByDate(@PathVariable String day) {
        statisticsDailyService.createStatisticsByDay(day);
        return R.ok();
    }



    /**
     * @description: 查询统计结果
     *
     * @return {@link null}
     * @author  wangxihao
     * @email wangxh0108@163.comC
    **/
    @GetMapping("showchart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String, Object> map = statisticsDailyService.getChartData(begin, end, type);
        return R.ok().data(map);
    }
}

